home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / PCX_LIB.ARJ / PCX_INT.H < prev    next >
C/C++ Source or Header  |  1991-04-07  |  11KB  |  196 lines

  1. /* 
  2.  *************************************************************************
  3.  *
  4.  *  PCX_INT.H - PCX_LIB Library Internal Definitions Include File
  5.  *
  6.  *  Version:    1.00B
  7.  *
  8.  *  History:    91/02/14 - Created
  9.  *              91/04/01 - Release 1.00A
  10.  *              91/04/07 - Release 1.00B
  11.  *
  12.  *  Compiler:   Microsoft C V6.0
  13.  *
  14.  *  Author:     Ian Ashdown, P.Eng.
  15.  *              byHeart Software
  16.  *              620 Ballantree Road
  17.  *              West Vancouver, B.C.
  18.  *              Canada V7S 1W3
  19.  *              Tel. (604) 922-6148
  20.  *              Fax. (604) 987-7621
  21.  *
  22.  *  Copyright:  Public Domain
  23.  *
  24.  *************************************************************************
  25.  */
  26.  
  27. /*      DEFINITIONS                                                     */
  28.  
  29. #define _PCX_INT_H      1
  30.  
  31. #ifndef _PCX_EXT_H
  32. #include "PCX_EXT.H"    /* Get external PCX definitions, etc.           */
  33. #endif
  34.  
  35. #define PCX_HERC        0xff    /* Hercules 720 x 348 monochrome mode   */
  36.  
  37. #define PCX_COMP_FLAG   0xc0    /* Compressed data flag mask            */
  38. #define PCX_COMP_MASK   0x3f    /* Data repeat count mask               */
  39.  
  40. #define PCX_PAL_MASK    0x03    /* Palette interpretation mask          */
  41. #define PCX_EPAL_FLAG   0x0c    /* Extended palette flag                */
  42.  
  43. #define PCX_PAL_SIZE    16      /* File header palette size             */
  44. #define PCX_EPAL_SIZE   256     /* Extended palette size                */
  45.  
  46. #define PCX_MAXLINESZ   640     /* Maximum PCX line buffer size         */
  47.  
  48. /* Color graphics adapter color palette macros                          */
  49.  
  50. #define PCX_CGA_BKGND(x)        (x[0].red >> 4)    /* Background color  */
  51. #define PCX_CGA_BURST(x)        (x[1].red & 0x80)  /* Color burst       */
  52. #define PCX_CGA_SELECT(x)       (x[1].red & 0x40)  /* Palette selector  */
  53. #define PCX_CGA_INTENSITY(x)    (x[1].red & 0x20)  /* Intensity         */
  54.  
  55. typedef unsigned char BYTE;     /* 8-bit data type                      */
  56. typedef unsigned int WORD;      /* 16-bit data type                     */
  57.  
  58. /*      STRUCTURE DECLARATIONS                                          */
  59.  
  60. typedef struct pcx_pal  /* PCX palette array element                    */
  61. {
  62.   BYTE red;             /* Red intensity                                */
  63.   BYTE green;           /* Green intensity                              */
  64.   BYTE blue;            /* Blue intensity                               */
  65. }
  66. PCX_PAL;
  67.  
  68. typedef struct pcx_hdr  /* PCX file header (Version 5)                  */
  69. {
  70.   BYTE pcx_id;          /* Always 0x0a for PCX files                    */
  71.   BYTE version;         /* Version number                               */
  72.   BYTE encoding;        /* 1 = PCX run length encoding                  */
  73.   BYTE bppixel;         /* Number of bits/pixel per color plane         */
  74.   WORD xul;             /* X-position of upper left corner              */
  75.   WORD yul;             /* Y-position of upper left corner              */
  76.   WORD xlr;             /* X-position of lower right corner             */
  77.   WORD ylr;             /* Y-position of lower right corner             */
  78.   WORD horz_res;        /* Horizontal resolution                        */
  79.   WORD vert_res;        /* Vertical resolution                          */
  80.   PCX_PAL palette[PCX_PAL_SIZE];        /* Hardware R-G-B palette       */
  81.   BYTE reserved;        /* Unused in Version 5                          */
  82.   BYTE nplanes;         /* Number of color planes                       */
  83.   WORD bppscan;         /* Number of bytes per plane scan line          */
  84.   WORD palette_type;    /* Palette interpretation                       */
  85.   WORD scrn_width;      /* Horizontal screen size in pixels             */
  86.   WORD scrn_height;     /* Vertical screen size in pixels               */
  87.   BYTE filler[54];      /* Padding to fill out 128-byte header          */
  88.  
  89.   /* Notes:                                                             */
  90.   /*                                                                    */
  91.   /*   1.  The "version" member may be one of the following:            */
  92.   /*                                                                    */
  93.   /*         0 - PC Paintbrush Version 2.5                              */
  94.   /*         2 - PC Paintbrush Version 2.8 (with palette information)   */
  95.   /*         3 - PC Paintbrush Version 2.8 (w/o palette information)    */
  96.   /*         4 - PC Paintbrush for Windows (PC Paintbrush Plus for      */
  97.   /*             Windows and Windows 3.0 Paintbrush use Version 5)      */
  98.   /*         5 - PC Paintbrush 3.0 and greater (including PC Paintbrush */
  99.   /*             Plus and Publisher's Paintbrush)                       */
  100.   /*                                                                    */
  101.   /*   2.  ZSoft Corporation has reserved the right to change the       */
  102.   /*       encoding method in future versions for better image          */
  103.   /*       compression performance.  The "encoding" member value may    */
  104.   /*       change accordingly.                                          */
  105.   /*                                                                    */
  106.   /*   3.  The value of the "bppixel" member depends on the type of     */
  107.   /*       video display adapter and its video mode.  Typical values    */
  108.   /*       are 1, 2, 4 and 8.                                           */
  109.   /*                                                                    */
  110.   /*   4.  The "xul", "yul", "xlr" and "ylr" members are zero-based and */
  111.   /*       and inclusive values indicating the position of the image on */
  112.   /*       the screen.  The display functions can ignore this           */
  113.   /*       information if desired.                                      */
  114.   /*                                                                    */
  115.   /*   5.  The "horz_res" and "vert_res" members refer to the "dots per */
  116.   /*       inch" resolution of the scanning device used to create the   */
  117.   /*       image.  For images created on video display adapters, these  */
  118.   /*       values typically refer to the horizontal and vertical        */
  119.   /*       resolutions in pixels (e.g. - 640 x 350 for an EGA display). */
  120.   /*                                                                    */
  121.   /*       The display function ignore these members, as some programs  */
  122.   /*       programs do not bother to initialize them when creating PCX  */
  123.   /*       image files.                                                 */
  124.   /*                                                                    */
  125.   /*   6.  The "palette" member is typically left uninitialized if an   */
  126.   /*       extended 256-color palette is appended to the PCX image      */
  127.   /*       file.                                                        */
  128.   /*                                                                    */
  129.   /*   7.  The "reserved" member used to contain the MS-DOS video mode  */
  130.   /*       that the PCX image was intended to be displayed under.  This */
  131.   /*       member is ignored in Version 5.  ZSoft recommends that it be */
  132.   /*       set to zero.                                                 */
  133.   /*                                                                    */
  134.   /*   8.  The value of the "nplanes" member depends on the type of     */
  135.   /*       video display adapter and its video mode.  Typical values    */
  136.   /*       are 1, 2, 3 and 4.                                           */
  137.   /*                                                                    */
  138.   /*   9.  The value of the "bppscan" member should be an even number   */
  139.   /*       (for compatibility with some existing commercial programs.)  */
  140.   /*       It indicates the number of bytes required to buffer a        */
  141.   /*       decoded scan line for one color plane.                       */
  142.   /*                                                                    */
  143.   /*  10.  The "palette_type" member indicates whether the palette      */
  144.   /*       represents a color or grayscale palette.  It is a bit-mapped */
  145.   /*       variable (only the lowest two bits are significant; the      */
  146.   /*       others are ignored) with two possible values:                */
  147.   /*                                                                    */
  148.   /*         0x01 - color or black & white                              */
  149.   /*         0x02 - grayscale                                           */
  150.   /*                                                                    */
  151.   /*       If "grayscale" is indicated, the file color palette must be  */
  152.   /*       set to shades of gray.  The file decoding functions can then */
  153.   /*       either use this palette or assume a default grayscale        */
  154.   /*       palette if necessary.                                        */
  155.   /*                                                                    */
  156.   /*       PC Paintbrush IV and IV Plus ignore this member.             */
  157.   /*                                                                    */
  158.   /*  11.  The "scrn_width" and "scrn_height" members were added for    */
  159.   /*       PC Paintbrush IV Version 1.02 and IV Plus Version 1.0.  They */
  160.   /*       may not be initialized in some older Version 5 PCX files, or */
  161.   /*       the "scrn_width" member may be initialized with the screen   */
  162.   /*       height and the "scrn_height" member uninitialized.  ZSoft    */
  163.   /*       recommends that this information be ignored.                 */
  164.   /*                                                                    */
  165.   /*  12.  ZSoft recommends that the "filler" bytes be set to zero.     */
  166. }
  167. PCX_HDR;
  168.  
  169. typedef struct pcx_workblk      /* PCX image file workblock             */
  170. {
  171.   /* File header                                                        */
  172.  
  173.   FILE *fp;                     /* PCX image file pointer               */
  174.   PCX_HDR header;               /* PCX image file header                */
  175.   PCX_PAL *palettep;            /* Color palette pointer                */
  176.   BOOL epal_flag;               /* Extended color palette flag          */
  177.  
  178.   /* Image manipulation variables                                       */
  179.  
  180.   int num_bytes;                /* Number of bytes to display           */
  181.   int mask;                     /* Unseen pixels mask                   */
  182.   unsigned long page_offset;    /* Display page address offset          */
  183.  
  184.   /* Image manipulation function pointer                                */
  185.  
  186.   void (*pcx_funcp)(struct pcx_workblk *, unsigned char _far *, int);
  187. }
  188. PCX_WORKBLK;
  189.  
  190. /* FUNCTIONS PROTOTYPES                                                 */
  191.  
  192. extern BOOL pcx_close(PCX_WORKBLK *);
  193.  
  194. extern PCX_WORKBLK *pcx_open(char *, BOOL);
  195.  
  196.